package com.entertainment.ticketing.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "event_info",
        indexes = {
                @Index(name = "idx_category", columnList = "category"),
                @Index(name = "idx_status", columnList = "status"),
                @Index(name = "idx_start_time", columnList = "start_time")
        })
public class EventInfo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, length = 200)
    private String title;

    @Lob
    private String description;

    @Column(nullable = false, length = 50)
    private String category; // CONCERT/DRAMA/MOVIE

    @Column(nullable = false, length = 200)
    private String venue;

    @Column(nullable = false, length = 500)
    private String address;

    @Column(name = "start_time", nullable = false)
    private LocalDateTime startTime;

    @Column(name = "end_time", nullable = false)
    private LocalDateTime endTime;

    @Column(name = "poster_url", length = 255)
    private String posterUrl;

    @Column(nullable = false)
    private Byte status = 1; // 1-正常，2-已结束，0-已取消

    @Column(name = "total_seats", nullable = false)
    private Integer totalSeats = 0;

    @Column(name = "available_seats", nullable = false)
    private Integer availableSeats = 0;

    @CreationTimestamp
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;

    @UpdateTimestamp
    @Column(name = "updated_at", nullable = false)
    private LocalDateTime updatedAt;
}